﻿namespace UserVoiceApi.Tests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class ApiTests
    {
        [TestMethod]
        public void ShouldGetCommentsForSuggestions()
        {
            var comments = Api.GetCommentsForSuggestions("1274823", "89049", "webmatrixhelpers", "GEDy0uM3NS5LH2r6eeBLYQ");

            Assert.IsNotNull(comments);
        }

        [TestMethod]
        public void ShouldGetSuggestionsSearch()
        {
            var suggestions = Api.GetSuggestionsSearch("89049", "idea", "webmatrixhelpers", "GEDy0uM3NS5LH2r6eeBLYQ");

            Assert.IsNotNull(suggestions);
        }

        [TestMethod]
        public void ShouldGetSuggestionList()
        {
            var suggestions = Api.GetSuggestionsList("89049", "webmatrixhelpers", "GEDy0uM3NS5LH2r6eeBLYQ");

            Assert.IsNotNull(suggestions);
            Assert.AreEqual("1274823", suggestions[0].id.ToString());
        }

        [TestMethod]
        public void ShouldGetForum()
        {
            var forum = Api.GetForum("89049", "webmatrixhelpers", "GEDy0uM3NS5LH2r6eeBLYQ");

            Assert.IsNotNull(forum);
            Assert.AreEqual("89049", forum.Id.ToString());
        }
        
        [TestMethod]
        public void ShouldGetForumList()
        {
            var forumList = Api.GetForumList("webmatrixhelpers", "GEDy0uM3NS5LH2r6eeBLYQ");
            
            Assert.IsNotNull(forumList);
            Assert.AreEqual("89049", forumList[0].Id.ToString());
        }

        [TestMethod]
        [ExpectedException(typeof(System.Net.WebException))]
        public void ShouldNotGetForumListBadRequest()
        {
            var forumList = Api.GetForumList("webmatrixhelpers", "GEDy0uM3NS5LH2r6eeBLYQ2");
            Assert.IsNull(forumList);

            forumList = Api.GetForumList("webmatrixhelpersNotMyAddress", "GEDy0uM3NS5LH2r6eeBLYQ");
            Assert.IsNull(forumList);
        }
    }
}
